import {Component, OnInit} from '@angular/core';
import {ArrayUtils, CommonUtils} from 'great-jsutils';

@Component({
  selector: 'app-array-test03',
  templateUrl: './array-test03.component.html',
  styleUrls: ['./array-test03.component.less']
})
export class ArrayTest03Component implements OnInit {

  json2Str = `
  [
      {
        "name": "济南市"
      }
  ]
  `;
  json1HtmlStr = null;

  constructor() {
  }

  ngOnInit() {
  }

  updateKey() {
    const jsonObj = JSON.parse(this.json2Str);
    if (jsonObj) {
      ArrayUtils.updateKey(jsonObj, {}, (v) => {
        v.id = CommonUtils.uuid();
      });
      this.json2Str = JSON.stringify(jsonObj, undefined, 2);
    }
  }

}
